home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.1B1 / AIncludes / GXMath.a < prev    next >
Encoding:
Text File  |  1995-04-18  |  9.8 KB  |  590 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        GXMath.a
  3. ;
  4. ;    Contains:    QuickDraw GX math routine interfaces.
  5. ;
  6. ;    Version:    Technology:    Quickdraw GX 1.1
  7. ;                Package:    Universal Interfaces 2.1ß1 in “MPW Prerelease” on ETO #17
  8. ;
  9. ;    Copyright:    © 1984-1995 by Apple Computer, Inc.
  10. ;                All rights reserved.
  11. ;
  12. ;    Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13. ;                stack.  Include the file and version information (from above)
  14. ;                in the problem description and send to:
  15. ;                    Internet:    apple.bugs@applelink.apple.com
  16. ;                    AppleLink:    APPLE.BUGS
  17. ;
  18. ;
  19.  
  20.     IF &TYPE('__GXMATH__') = 'UNDEFINED' THEN
  21. __GXMATH__ SET 1
  22.  
  23.  
  24.     IF &TYPE('__CONDITIONALMACROS__') = 'UNDEFINED' THEN
  25.     include 'ConditionalMacros.a'
  26.     ENDIF
  27.  
  28.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  29.     include 'Types.a'
  30.     ENDIF
  31.  
  32.     IF &TYPE('__FIXMATH__') = 'UNDEFINED' THEN
  33.     include 'FixMath.a'
  34.     ENDIF
  35.     mathTypesIncludes: SET 1
  36. gxPoint                 RECORD    0
  37. x                         ds.l   1        ; offset: $0 (0)
  38. y                         ds.l   1        ; offset: $4 (4)
  39. sizeof                     EQU *            ; size:   $8 (8)
  40.                         ENDR
  41.  
  42. ; typedef struct gxPoint     gxPoint
  43. ; typedef unsigned short     gxColorValue
  44. gxPolar                 RECORD    0
  45. radius                     ds.l   1        ; offset: $0 (0)
  46. angle                     ds.l   1        ; offset: $4 (4)
  47. sizeof                     EQU *            ; size:   $8 (8)
  48.                         ENDR
  49.  
  50. gxMapping                 RECORD    0
  51. map                         ds.l   9        ; offset: $0 (0)
  52. sizeof                     EQU *            ; size:   $24 (36)
  53.                         ENDR
  54.  
  55. ; typedef struct gxPolar     gxPolar
  56. ; typedef struct gxMapping     gxMapping
  57.  
  58. gxColorValue1                    EQU        $0000FFFF            ; gxColorValue 1.0 
  59. gxPositiveInfinity                EQU        $7FFFFFFF            ; for Fixed and Fract 
  60. gxNegativeInfinity                EQU        $80000000            ; for Fixed and Fract 
  61.  
  62.     mathRoutinesIncludes: SET 1
  63. ;
  64. ; gxMapping *CopyToMapping(gxMapping *target, const gxMapping *source)
  65. ;
  66.     IF ¬ GENERATINGCFM THEN
  67.         Macro
  68.         _CopyToMapping
  69.             move.w    #$31,d0
  70.             dc.w     $A832
  71.         EndM
  72.     ELSE
  73.         IMPORT_CFM_FUNCTION    CopyToMapping
  74.     ENDIF
  75.  
  76. ;
  77. ; gxMapping *InvertMapping(gxMapping *target, const gxMapping *source)
  78. ;
  79.     IF ¬ GENERATINGCFM THEN
  80.         Macro
  81.         _InvertMapping
  82.             move.w    #$32,d0
  83.             dc.w     $A832
  84.         EndM
  85.     ELSE
  86.         IMPORT_CFM_FUNCTION    InvertMapping
  87.     ENDIF
  88.  
  89. ;
  90. ; gxMapping *MapMapping(gxMapping *target, const gxMapping *source)
  91. ;
  92.     IF ¬ GENERATINGCFM THEN
  93.         Macro
  94.         _MapMapping
  95.             move.w    #$33,d0
  96.             dc.w     $A832
  97.         EndM
  98.     ELSE
  99.         IMPORT_CFM_FUNCTION    MapMapping
  100.     ENDIF
  101.  
  102. ;
  103. ; gxMapping *MoveMapping(gxMapping *target, Fixed hOffset, Fixed vOffset)
  104. ;
  105.     IF ¬ GENERATINGCFM THEN
  106.         Macro
  107.         _MoveMapping
  108.             move.w    #$34,d0
  109.             dc.w     $A832
  110.         EndM
  111.     ELSE
  112.         IMPORT_CFM_FUNCTION    MoveMapping
  113.     ENDIF
  114.  
  115. ;
  116. ; gxMapping *MoveMappingTo(gxMapping *target, Fixed hPosition, Fixed vPosition)
  117. ;
  118.     IF ¬ GENERATINGCFM THEN
  119.         Macro
  120.         _MoveMappingTo
  121.             move.w    #$35,d0
  122.             dc.w     $A832
  123.         EndM
  124.     ELSE
  125.         IMPORT_CFM_FUNCTION    MoveMappingTo
  126.     ENDIF
  127.  
  128. ;
  129. ; gxMapping *NormalizeMapping(gxMapping *target)
  130. ;
  131.     IF ¬ GENERATINGCFM THEN
  132.         Macro
  133.         _NormalizeMapping
  134.             move.w    #$36,d0
  135.             dc.w     $A832
  136.         EndM
  137.     ELSE
  138.         IMPORT_CFM_FUNCTION    NormalizeMapping
  139.     ENDIF
  140.  
  141. ;
  142. ; gxMapping *RotateMapping(gxMapping *target, Fixed angle, Fixed xCenter, Fixed yCenter)
  143. ;
  144.     IF ¬ GENERATINGCFM THEN
  145.         Macro
  146.         _RotateMapping
  147.             move.w    #$37,d0
  148.             dc.w     $A832
  149.         EndM
  150.     ELSE
  151.         IMPORT_CFM_FUNCTION    RotateMapping
  152.     ENDIF
  153.  
  154. ;
  155. ; gxMapping *ScaleMapping(gxMapping *target, Fixed hFactor, Fixed vFactor, Fixed xCenter, Fixed yCenter)
  156. ;
  157.     IF ¬ GENERATINGCFM THEN
  158.         Macro
  159.         _ScaleMapping
  160.             move.w    #$38,d0
  161.             dc.w     $A832
  162.         EndM
  163.     ELSE
  164.         IMPORT_CFM_FUNCTION    ScaleMapping
  165.     ENDIF
  166.  
  167. ;
  168. ; gxMapping *ResetMapping(gxMapping *target)
  169. ;
  170.     IF ¬ GENERATINGCFM THEN
  171.         Macro
  172.         _ResetMapping
  173.             move.w    #$39,d0
  174.             dc.w     $A832
  175.         EndM
  176.     ELSE
  177.         IMPORT_CFM_FUNCTION    ResetMapping
  178.     ENDIF
  179.  
  180. ;
  181. ; gxMapping *SkewMapping(gxMapping *target, Fixed skewX, Fixed skewY, Fixed xCenter, Fixed yCenter)
  182. ;
  183.     IF ¬ GENERATINGCFM THEN
  184.         Macro
  185.         _SkewMapping
  186.             move.w    #$3a,d0
  187.             dc.w     $A832
  188.         EndM
  189.     ELSE
  190.         IMPORT_CFM_FUNCTION    SkewMapping
  191.     ENDIF
  192.  
  193. ;
  194. ; void MapPoints(const gxMapping *source, long count, gxPoint vector[])
  195. ;
  196.     IF ¬ GENERATINGCFM THEN
  197.         Macro
  198.         _MapPoints
  199.             move.w    #$3b,d0
  200.             dc.w     $A832
  201.         EndM
  202.     ELSE
  203.         IMPORT_CFM_FUNCTION    MapPoints
  204.     ENDIF
  205.  
  206. ;
  207. ; short FirstBit(unsigned long x)
  208. ;
  209.     IF ¬ GENERATINGCFM THEN
  210.         Macro
  211.         _FirstBit
  212.             move.w    #$3c,d0
  213.             dc.w     $A832
  214.         EndM
  215.     ELSE
  216.         IMPORT_CFM_FUNCTION    FirstBit
  217.     ENDIF
  218.  
  219. ;
  220. ; short WideScale(const wide *source)
  221. ;
  222.     IF ¬ GENERATINGCFM THEN
  223.         Macro
  224.         _WideScale
  225.             move.w    #$3d,d0
  226.             dc.w     $A832
  227.         EndM
  228.     ELSE
  229.         IMPORT_CFM_FUNCTION    WideScale
  230.     ENDIF
  231.  
  232. ;
  233. ; short LinearRoot(Fixed first, Fixed last, Fract t[])
  234. ;
  235.     IF ¬ GENERATINGCFM THEN
  236.         Macro
  237.         _LinearRoot
  238.             move.w    #$3e,d0
  239.             dc.w     $A832
  240.         EndM
  241.     ELSE
  242.         IMPORT_CFM_FUNCTION    LinearRoot
  243.     ENDIF
  244.  
  245. ;
  246. ; short QuadraticRoot(Fixed first, Fixed control, Fixed last, Fract t[])
  247. ;
  248.     IF ¬ GENERATINGCFM THEN
  249.         Macro
  250.         _QuadraticRoot
  251.             move.w    #$3f,d0
  252.             dc.w     $A832
  253.         EndM
  254.     ELSE
  255.         IMPORT_CFM_FUNCTION    QuadraticRoot
  256.     ENDIF
  257.  
  258. ;
  259. ; gxPoint *PolarToPoint(const gxPolar *ra, gxPoint *xy)
  260. ;
  261.     IF ¬ GENERATINGCFM THEN
  262.         Macro
  263.         _PolarToPoint
  264.             move.w    #$40,d0
  265.             dc.w     $A832
  266.         EndM
  267.     ELSE
  268.         IMPORT_CFM_FUNCTION    PolarToPoint
  269.     ENDIF
  270.  
  271. ;
  272. ; gxPolar *PointToPolar(const gxPoint *xy, gxPolar *ra)
  273. ;
  274.     IF ¬ GENERATINGCFM THEN
  275.         Macro
  276.         _PointToPolar
  277.             move.w    #$41,d0
  278.             dc.w     $A832
  279.         EndM
  280.     ELSE
  281.         IMPORT_CFM_FUNCTION    PointToPolar
  282.     ENDIF
  283.  
  284. ;
  285. ; Fract FractCubeRoot(Fract source)
  286. ;
  287.     IF ¬ GENERATINGCFM THEN
  288.         Macro
  289.         _FractCubeRoot
  290.             move.w    #$42,d0
  291.             dc.w     $A832
  292.         EndM
  293.     ELSE
  294.         IMPORT_CFM_FUNCTION    FractCubeRoot
  295.     ENDIF
  296.  
  297. ;
  298. ; Fract FractDivide(Fract dividend, Fract divisor)
  299. ;
  300.     IF ¬ GENERATINGCFM THEN
  301.         Macro
  302.         _FractDivide
  303.             move.w    #$43,d0
  304.             dc.w     $A832
  305.         EndM
  306.     ELSE
  307.         IMPORT_CFM_FUNCTION    FractDivide
  308.     ENDIF
  309.  
  310. ;
  311. ; Fract FractMultiply(Fract multiplicand, Fract multiplier)
  312. ;
  313.     IF ¬ GENERATINGCFM THEN
  314.         Macro
  315.         _FractMultiply
  316.             move.w    #$44,d0
  317.             dc.w     $A832
  318.         EndM
  319.     ELSE
  320.         IMPORT_CFM_FUNCTION    FractMultiply
  321.     ENDIF
  322.  
  323. ;
  324. ; Fract FractSineCosine(Fixed degrees, Fract *cosine)
  325. ;
  326.     IF ¬ GENERATINGCFM THEN
  327.         Macro
  328.         _FractSineCosine
  329.             move.w    #$45,d0
  330.             dc.w     $A832
  331.         EndM
  332.     ELSE
  333.         IMPORT_CFM_FUNCTION    FractSineCosine
  334.     ENDIF
  335.  
  336. ;
  337. ; Fract FractSquareRoot(Fract source)
  338. ;
  339.     IF ¬ GENERATINGCFM THEN
  340.         Macro
  341.         _FractSquareRoot
  342.             move.w    #$46,d0
  343.             dc.w     $A832
  344.         EndM
  345.     ELSE
  346.         IMPORT_CFM_FUNCTION    FractSquareRoot
  347.     ENDIF
  348.  
  349. ;
  350. ; Fixed FixedDivide(Fixed dividend, Fixed divisor)
  351. ;
  352.     IF ¬ GENERATINGCFM THEN
  353.         Macro
  354.         _FixedDivide
  355.             move.w    #$47,d0
  356.             dc.w     $A832
  357.         EndM
  358.     ELSE
  359.         IMPORT_CFM_FUNCTION    FixedDivide
  360.     ENDIF
  361.  
  362. ;
  363. ; Fixed FixedMultiply(Fixed multiplicand, Fixed multiplier)
  364. ;
  365.     IF ¬ GENERATINGCFM THEN
  366.         Macro
  367.         _FixedMultiply
  368.             move.w    #$48,d0
  369.             dc.w     $A832
  370.         EndM
  371.     ELSE
  372.         IMPORT_CFM_FUNCTION    FixedMultiply
  373.     ENDIF
  374.  
  375. ; This next call is (source * multiplier / divisor) -- it avoids underflow, overflow by using wides 
  376. ;
  377. ; long MultiplyDivide(long source, long multiplier, long divisor)
  378. ;
  379.     IF ¬ GENERATINGCFM THEN
  380.         Macro
  381.         _MultiplyDivide
  382.             move.w    #$49,d0
  383.             dc.w     $A832
  384.         EndM
  385.     ELSE
  386.         IMPORT_CFM_FUNCTION    MultiplyDivide
  387.     ENDIF
  388.  
  389. ;
  390. ; unsigned long Magnitude(long deltaX, long deltaY)
  391. ;
  392.     IF ¬ GENERATINGCFM THEN
  393.         Macro
  394.         _Magnitude
  395.             move.w    #$4a,d0
  396.             dc.w     $A832
  397.         EndM
  398.     ELSE
  399.         IMPORT_CFM_FUNCTION    Magnitude
  400.     ENDIF
  401.  
  402. ;
  403. ; long VectorMultiplyDivide(long count, const long *vector1, long step1, const long *vector2, long step2, long divisor)
  404. ;
  405.     IF ¬ GENERATINGCFM THEN
  406.         Macro
  407.         _VectorMultiplyDivide
  408.             move.w    #$4b,d0
  409.             dc.w     $A832
  410.         EndM
  411.     ELSE
  412.         IMPORT_CFM_FUNCTION    VectorMultiplyDivide
  413.     ENDIF
  414.  
  415. ; wide operations are defined within FixMath.h only for PowerPC 
  416.     IF ¬ GENERATINGPOWERPC  THEN
  417. ;
  418. ; wide *WideAdd(wide *target, const wide *source)
  419. ;
  420.     IF ¬ GENERATINGCFM THEN
  421.         Macro
  422.         _WideAdd
  423.             move.w    #$4c,d0
  424.             dc.w     $A832
  425.         EndM
  426.     ELSE
  427.         IMPORT_CFM_FUNCTION    WideAdd
  428.     ENDIF
  429.  
  430. ;
  431. ; short WideCompare(const wide *target, const wide *source)
  432. ;
  433.     IF ¬ GENERATINGCFM THEN
  434.         Macro
  435.         _WideCompare
  436.             move.w    #$4d,d0
  437.             dc.w     $A832
  438.         EndM
  439.     ELSE
  440.         IMPORT_CFM_FUNCTION    WideCompare
  441.     ENDIF
  442.  
  443. ;
  444. ; wide *WideNegate(wide *target)
  445. ;
  446.     IF ¬ GENERATINGCFM THEN
  447.         Macro
  448.         _WideNegate
  449.             move.w    #$4e,d0
  450.             dc.w     $A832
  451.         EndM
  452.     ELSE
  453.         IMPORT_CFM_FUNCTION    WideNegate
  454.     ENDIF
  455.  
  456. ;
  457. ; wide *WideShift(wide *target, long shift)
  458. ;
  459.     IF ¬ GENERATINGCFM THEN
  460.         Macro
  461.         _WideShift
  462.             move.w    #$4f,d0
  463.             dc.w     $A832
  464.         EndM
  465.     ELSE
  466.         IMPORT_CFM_FUNCTION    WideShift
  467.     ENDIF
  468.  
  469. ;
  470. ; unsigned long WideSquareRoot(const wide *source)
  471. ;
  472.     IF ¬ GENERATINGCFM THEN
  473.         Macro
  474.         _WideSquareRoot
  475.             move.w    #$50,d0
  476.             dc.w     $A832
  477.         EndM
  478.     ELSE
  479.         IMPORT_CFM_FUNCTION    WideSquareRoot
  480.     ENDIF
  481.  
  482. ;
  483. ; wide *WideSubtract(wide *target, const wide *source)
  484. ;
  485.     IF ¬ GENERATINGCFM THEN
  486.         Macro
  487.         _WideSubtract
  488.             move.w    #$51,d0
  489.             dc.w     $A832
  490.         EndM
  491.     ELSE
  492.         IMPORT_CFM_FUNCTION    WideSubtract
  493.     ENDIF
  494.  
  495. ;
  496. ; wide *WideMultiply(long multiplicand, long multiplier, wide *target)
  497. ;
  498.     IF ¬ GENERATINGCFM THEN
  499.         Macro
  500.         _WideMultiply
  501.             move.w    #$52,d0
  502.             dc.w     $A832
  503.         EndM
  504.     ELSE
  505.         IMPORT_CFM_FUNCTION    WideMultiply
  506.     ENDIF
  507.  
  508. ; returns the quotient 
  509. ;
  510. ; long WideDivide(const wide *dividend, long divisor, long *remainder)
  511. ;
  512.     IF ¬ GENERATINGCFM THEN
  513.         Macro
  514.         _WideDivide
  515.             move.w    #$53,d0
  516.             dc.w     $A832
  517.         EndM
  518.     ELSE
  519.         IMPORT_CFM_FUNCTION    WideDivide
  520.     ENDIF
  521.  
  522. ; quotient replaces dividend 
  523. ;
  524. ; wide *WideWideDivide(wide *dividend, long divisor, long *remainder)
  525. ;
  526.     IF ¬ GENERATINGCFM THEN
  527.         Macro
  528.         _WideWideDivide
  529.             move.w    #$55,d0
  530.             dc.w     $A832
  531.         EndM
  532.     ELSE
  533.         IMPORT_CFM_FUNCTION    WideWideDivide
  534.     ENDIF
  535.  
  536.     ENDIF
  537. ;
  538. ; wide *VectorMultiply(long count, const long *vector1, long step1, const long *vector2, long step2, wide *dot)
  539. ;
  540.     IF ¬ GENERATINGCFM THEN
  541.         Macro
  542.         _VectorMultiply
  543.             move.w    #$54,d0
  544.             dc.w     $A832
  545.         EndM
  546.     ELSE
  547.         IMPORT_CFM_FUNCTION    VectorMultiply
  548.     ENDIF
  549.  
  550. ;
  551. ; unsigned long RandomBits(long count, long focus)
  552. ;
  553.     IF ¬ GENERATINGCFM THEN
  554.         Macro
  555.         _RandomBits
  556.             move.w    #$56,d0
  557.             dc.w     $A832
  558.         EndM
  559.     ELSE
  560.         IMPORT_CFM_FUNCTION    RandomBits
  561.     ENDIF
  562.  
  563. ;
  564. ; void SetRandomSeed(const wide *seed)
  565. ;
  566.     IF ¬ GENERATINGCFM THEN
  567.         Macro
  568.         _SetRandomSeed
  569.             move.w    #$57,d0
  570.             dc.w     $A832
  571.         EndM
  572.     ELSE
  573.         IMPORT_CFM_FUNCTION    SetRandomSeed
  574.     ENDIF
  575.  
  576. ;
  577. ; wide *GetRandomSeed(wide *seed)
  578. ;
  579.     IF ¬ GENERATINGCFM THEN
  580.         Macro
  581.         _GetRandomSeed
  582.             move.w    #$58,d0
  583.             dc.w     $A832
  584.         EndM
  585.     ELSE
  586.         IMPORT_CFM_FUNCTION    GetRandomSeed
  587.     ENDIF
  588.  
  589.     ENDIF ; __GXMATH__
  590.